
require('font-awesome-webpack')


//搜索高亮

// searchTarget(this.searchText,'searchEl') ;
window.searchTarget = function(target,searchEl) {
    if(!target)  return ;
    //去除前后空格
    let str = target.replace(/(^\s*)|(\s*$)/g, "") ;
    //将多个空格合并为一个空格
    let strs = str.replace(/\s+/g, ' ') ;
    //将字符串分割为数组
    let searchTextArry = strs.split(" "); 

    let targetObject = Array.from(document.getElementsByClassName(searchEl));  //获取所有需要筛选的数据节点

    targetObject.forEach(function(elmentDom,index) {
        searchTextArry.forEach(function(item) {
            let html = elmentDom.innerHTML ;
            let reg = new RegExp(item,"g"); 
            let newHtml = html.replace(reg,'<span class="highlight">'+item+'</span>')//处理HTML字符串，为目标文本加上样式，即替换对应的HTML结构
            document.getElementsByClassName(searchEl)[index].innerHTML = newHtml ;
        });
    })
}
import qs from 'qs' ;
import axios from 'axios'

import $ from 'jquery' ;
import cookie from 'jquery.cookie' ;

window.$ = $ ;
// axios.defaults.withCredentials=true
window.ajax = {
    get:function ( options ) {
        return axios.get(this.getUrl(options.url),{
            params:Object.assign({
                ref:Date.now()
            },options.data),
            crossOrigin: true,
            withCredentials:true
        });
    },

    getUrl:function ( url ) {
        let api = "http://api.wyMusic.yutao2012.com";
        return api + url;
    },

    post:function ( options ) {
        return axios.post(this.getUrl(options.url),options.data);
    }
};